#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>
using namespace std;

class Solution {
public:
    vector<string> findLongestSubarray(vector<string>& array)
    {
        unordered_map<int, int> hash;
        hash[0] = -1;
        int cnt = 0;
        int len = 0;
        int left = 0, right = 0;
        for (int i = 0; i < array.size(); i++)
        {
            if (isalpha(array[i][0]))
                cnt++;
            else
                cnt--;
            if (hash.count(cnt))
            {
                if (len < i - hash[cnt])
                {
                    len = i - hash[cnt];
                    left = hash[cnt] + 1;
                    right = i;
                }
            }
            if (hash.count(cnt) == 0)
                hash[cnt] = i;
        }
        if (len == 0)
            return {};
        return { array.begin() + left, array.begin() + right + 1 };
    }
};